How to use test_recording method in SeleniumBase

Best Python code snippet using SeleniumBase

tests_recording.py

Source:tests_recording.py Github

copy

Full Screen

1from django.test import TestCase2from rest_framework.test import APITestCase3from rest_framework import status4from django.utils import timezone5from users.models import User, Administrator6from language.models import (7 Recording,8)9class BaseTestCase(APITestCase):10 def setUp(self):11 self.user = User.objects.create(12 username="testuser001",13 first_name="Test",14 last_name="user 001",15 email="test@countable.ca",16 is_staff=True,17 is_superuser=True,18 )19 self.user.set_password("password")20 self.user.save()21class RecordingAPITests(BaseTestCase):22 def setUp(self):23 super().setUp()24 self.now = timezone.now()25 ###### ONE TEST TESTS ONLY ONE SCENARIO ######26 def test_recording_detail(self):27 """28 Ensure we can retrieve a newly created recording object.29 """30 test_recording = Recording.objects.create(31 speaker = "Test speaker",32 recorder = "Test recorder",33 created = self.now,34 date_recorded = self.now,35 )36 response = self.client.get(37 "/api/recording/{}/".format(test_recording.id), format="json"38 )39 self.assertEqual(response.status_code, status.HTTP_200_OK)40 self.assertEqual(response.data["speaker"], test_recording.speaker)41 self.assertEqual(response.data["recorder"], test_recording.recorder)42 def test_recording_post(self):43 """44 Ensure recording API POST method API works45 """46 # Must be logged in to verify a media.47 self.assertTrue(self.client.login(username="testuser001", password="password"))48 # Check we're logged in49 response = self.client.get("/api/user/auth/")50 self.assertEqual(response.json()["is_authenticated"], True)51 response = self.client.post(52 "/api/recording/",53 {54 "speaker": "Test speaker",55 "recorder": "Test recorder",56 "date_recorded": "2019-01-01"57 },58 format="json",59 )60 self.assertEqual(response.status_code, status.HTTP_201_CREATED)61 created_id = response.json()["id"]62 recording = Recording.objects.get(pk=created_id)63 self.assertEqual(recording.speaker, "Test speaker")64 self.assertEqual(recording.recorder, "Test recorder")65 def test_recording_patch(self):66 """67 Ensure recording API PATCH method API works68 """69 # Must be logged in to verify a media.70 self.assertTrue(self.client.login(username="testuser001", password="password"))71 # Check we're logged in72 response = self.client.get("/api/user/auth/")73 self.assertEqual(response.json()["is_authenticated"], True)74 test_recording = Recording.objects.create(75 speaker = "Test speaker",76 recorder = "Test recorder",77 created = self.now,78 date_recorded = self.now,79 )80 response = self.client.patch(81 "/api/recording/{}/".format(test_recording.id),82 {83 "speaker": "Test speaker2",84 "recorder": "Test recorder2",85 },86 format="json",87 )88 self.assertEqual(response.status_code, status.HTTP_200_OK)89 recording = Recording.objects.get(pk=test_recording.id)90 self.assertEqual(recording.speaker, "Test speaker2")91 self.assertEqual(recording.recorder, "Test recorder2")92 def test_recording_delete(self):93 """94 Ensure recording API DELETE method API works95 """96 test_recording = Recording.objects.create(97 speaker = "Test speaker",98 recorder = "Test recorder",99 created = self.now,100 date_recorded = self.now,101 )102 103 response = self.client.delete(104 "/api/recording/{}/".format(test_recording.id), format="json"105 )...

Full Screen

Full Screen

tests.py

Source:tests.py Github

copy

Full Screen

1from django.test import TestCase2from users.tests import RegisterLoginTest as rl3from .models import Recording, Song4from users.models import MyUser5from django.conf import settings6 7class SongBookTest(TestCase): 8 def test_song_book_template_used(self):9 rl.sign_up_and_login(self)10 response = self.client.get('/song_book/1/')11 self.assertTemplateUsed(response, 'song_book/base_songbook.html')12 def sign_in_song_post(self):13 rl.sign_up_and_login(self)14 self.client.post('/song_book/1/song_post/to_learn/', data={'to_learn_input' : 'Starman'})15 16 def test_song_input_saved(self):17 self.sign_in_song_post()18 new_item = Song.objects.first()19 self.assertEqual(new_item.text, 'Starman')20 self.assertEqual(new_item.status, 'to_learn')21 22 def test_song_delete(self):23 self.sign_in_song_post()24 the_user = MyUser.objects.get(pk=1)25 self.client.post('/song_book/1/song_post/rusty/', data={'rusty_input' : 'Under Pressure'})26 songs = Song.objects.filter(user=the_user)27 self.assertEqual(songs.count(), 2)28 self.client.post('/song_book/1/song_delete/2/')29 self.assertEqual(songs.count(), 1)30 31 def test_song_move(self):32 self.sign_in_song_post()33 self.client.post('/song_book/1/song_post/learning/', data={'learning_input' : 'Life On Mars'})34 self.client.post('/song_book/1/song_post/rusty/', data={'rusty_input' : 'Under Pressure'})35 36 self.client.post('/song_book/song_move/', data={'user_pk': 1, 'song_pk': 1,37 'list_index': 0, 'status': 'rusty',})38 the_song = Song.objects.get(pk = 1)39 self.assertEqual(the_song.list_index, 0)40 self.assertEqual(the_song.status, 'rusty')41 42 def test_song_note(self):43 self.sign_in_song_post()44 self.client.post('/song_book/song_note/', data={ 'user_pk': 1, 'song_pk': 1, 'note_input': 'Verse chords are D, Am, C and G'})45 the_song = Song.objects.get(pk = 1)46 self.assertEqual(the_song.note, 'Verse chords are D, Am, C and G')47 def test_song_video(self):48 self.sign_in_song_post()49 self.client.post('/song_book/1/song_video/1/', data={'link_input': 'https://www.youtube.com/watch?v=aWOppc3Udto&ab_channel=LeftHandedGuitarist'})50 the_song = Song.objects.get(pk = 1)51 self.assertEqual(the_song.video, 'https://www.youtube.com/embed/aWOppc3Udto')52 53 def test_song_recording(self):54 self.sign_in_song_post()55 file = open('/home/anwin/axr005/song_book/media/test_recording.wav', 'rb')56 self.client.post('/song_book/1/song_recording/1/', data={'file': file, 'display_name':'test_recording'})57 the_recording = Recording.objects.get(pk = 1)58 self.assertEqual(the_recording.name, 'test_recording')59 def test_song_recording_delete(self):60 self.sign_in_song_post()61 file = open('/home/anwin/axr005/song_book/media/test_recording.wav', 'rb')62 self.client.post('/song_book/1/song_recording/1/', data={'file': file, 'display_name':'test_recording'})63 the_song = Song.objects.get(pk = 1)64 recordings = Recording.objects.filter(song=the_song)65 self.assertEqual(recordings.count(), 1)66 self.client.post('/song_book/1/song_recording_delete/1/1/')...

Full Screen

Full Screen

test_singularity_containers.py

Source:test_singularity_containers.py Github

copy

Full Screen

1import os2import shutil3import pytest4import spikeinterface.extractors as se5import spikeinterface.sorters as ss6os.environ['SINGULARITY_DISABLE_CACHE'] = 'true'7@pytest.fixture(autouse=True)8def work_dir(request, tmp_path):9 """10 This fixture, along with "run_kwargs" creates one folder per11 test function using built-in tmp_path pytest fixture12 The tmp_path will be the working directory for the test function13 At the end of the each test function, a clean up will be done14 """15 os.chdir(tmp_path)16 yield17 os.chdir(request.config.invocation_dir)18 shutil.rmtree(str(tmp_path))19@pytest.fixture20def run_kwargs(work_dir):21 test_recording, _ = se.toy_example(22 duration=30,23 seed=0,24 num_channels=64,25 num_segments=126 )27 test_recording = test_recording.save(name='toy')28 return dict(recording=test_recording, verbose=True, singularity_image=True)29def test_spykingcircus(run_kwargs):30 sorting = ss.run_spykingcircus(output_folder="spykingcircus", **run_kwargs)31 print(sorting)32def test_mountainsort4(run_kwargs):33 sorting = ss.run_mountainsort4(output_folder="mountainsort4", **run_kwargs)34 print(sorting)35def test_tridesclous(run_kwargs):36 sorting = ss.run_tridesclous(output_folder="tridesclous", **run_kwargs)37 print(sorting)38def test_klusta(run_kwargs):39 sorting = ss.run_klusta(output_folder="klusta", **run_kwargs)40 print(sorting)41def test_ironclust(run_kwargs):42 sorting = ss.run_ironclust(output_folder="ironclust", fGpu=False, **run_kwargs)43 print(sorting)44def test_waveclus(run_kwargs):45 sorting = ss.run_waveclus(output_folder="waveclus", **run_kwargs)46 print(sorting)47def test_hdsort(run_kwargs):48 sorting = ss.run_hdsort(output_folder="hdsort", **run_kwargs)49 print(sorting)50def test_kilosort1(run_kwargs):51 sorting = ss.run_kilosort(output_folder="kilosort", useGPU=False, **run_kwargs)52 print(sorting)53@pytest.mark.skip(reason="GPU required")54def test_kilosort2(run_kwargs):55 sorting = ss.run_kilosort2(output_folder="kilosort2", **run_kwargs)56 print(sorting)57@pytest.mark.skip(reason="GPU required")58def test_kilosort2_5(run_kwargs):59 sorting = ss.run_kilosort2_5(output_folder="kilosort2_5", **run_kwargs)60 print(sorting)61@pytest.mark.skip(reason="GPU required")62def test_kilosort3(run_kwargs):63 sorting = ss.run_kilosort3(output_folder="kilosort3", **run_kwargs)64 print(sorting)65@pytest.mark.skip(reason="GPU required")66def test_pykilosort(run_kwargs):67 sorting = ss.run_pykilosort(output_folder="pykilosort", **run_kwargs)...

Full Screen

Full Screen

recording_tests.py

Source:recording_tests.py Github

copy

Full Screen

1import unittest2class Test_Recording(unittest.TestCase):3 def test_recording(self):4 import recording5 import tempfile6 import os7 with open("test_data/test.h264", "rb") as fp:8 s = fp.read()9 r = recording.Recording(s, 2)10 r.cut(0, 1)11 with self.assertRaises(recording.RecordingException):12 r.cut(2, 1)13 temp_root = os.path.join(tempfile.gettempdir(), "test_recording")14 if not os.path.isdir(temp_root):15 os.makedirs(temp_root)16 temp_path = os.path.join(temp_root, r.name)17 r.save(temp_root)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful