-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from timatifey/release/1.1.0
Release/1.1.0
- Loading branch information
Showing
8 changed files
with
9,132 additions
and
1,499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: tests_backend | ||
|
||
on: | ||
push: | ||
branches: [ "main", "develop" ] | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ "3.10" ] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r backend/requirements.txt | ||
- name: Run Tests | ||
run: | | ||
python backend/manage.py test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: tests_frontend | ||
|
||
on: | ||
push: | ||
branches: [ "main", "develop" ] | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [ 19.x ] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install dependencies | ||
run: | | ||
cd frontend | ||
npm ci | ||
- name: Run tests | ||
run: | | ||
cd frontend | ||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from rest_framework import status | ||
from rest_framework.test import APIClient | ||
from django.test import SimpleTestCase | ||
from .utils import YouTubeVideo | ||
import json | ||
|
||
|
||
class YouGifTestCase(SimpleTestCase): | ||
|
||
def setUp(self): | ||
self.client = APIClient() | ||
|
||
def test_get_youtube_data(self): | ||
data = YouTubeVideo(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ&type=video') | ||
self.assertEqual(data.title, 'Rick Astley - Never Gonna Give You Up (Official Music Video)') | ||
self.assertEqual(data.duration, 212) | ||
|
||
def test_empty_request(self): | ||
response = self.client.get('/convert/') | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
def test_empty_times(self): | ||
response = self.client.get( | ||
'/convert/', | ||
**{'QUERY_STRING': 'url=https://www.youtube.com/watch?v=dQw4w9WgXcQ'} | ||
) | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual( | ||
json.loads(response.content).get('response'), | ||
'You need url, start_time, end_time params' | ||
) | ||
|
||
def test_time_greater_than_duration(self): | ||
response = self.client.get( | ||
'/convert/', | ||
**{'QUERY_STRING': 'url=https://www.youtube.com/watch?v=dQw4w9WgXcQ&start_time=0&end_time=500'} | ||
) | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual( | ||
json.loads(response.content).get('response'), | ||
'Not valid condition: 0 <= start time < end time <= video duration' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { | ||
convertSecondsToTimeString, | ||
convertTimeStringToSeconds, | ||
getTimeInSecondsFromYTTimeString | ||
} from "../src/helpers/time-converter"; | ||
|
||
test('Convert YouTube time string to seconds', () => { | ||
expect(getTimeInSecondsFromYTTimeString('PT0H1M30S')).toBe(90); | ||
}) | ||
|
||
test('Convert time string to seconds', () => { | ||
expect(convertTimeStringToSeconds('00:03:24')).toBe(204); | ||
}) | ||
|
||
test('Convert seconds to time string', () => { | ||
expect(convertSecondsToTimeString(20)).toBe('00:00:20'); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// jest.config.js | ||
const nextJest = require('next/jest') | ||
|
||
const createJestConfig = nextJest({ | ||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment | ||
dir: './', | ||
}) | ||
|
||
// Add any custom config to be passed to Jest | ||
/** @type {import('jest').Config} */ | ||
const customJestConfig = { | ||
// Add more setup options before each test is run | ||
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work | ||
moduleDirectories: ['node_modules', '<rootDir>/'], | ||
testEnvironment: 'jest-environment-jsdom', | ||
} | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
module.exports = createJestConfig(customJestConfig) |
Oops, something went wrong.