How to use test_delete_object method in tempest

Best Python code snippet using tempest_python

tests_models.py

Source:tests_models.py Github

copy

Full Screen

...92 " ---> test_Channel_with_attributs of ChannelTestCase : OK !")93 """94 test delete object95 """96 def test_delete_object(self):97 Channel.objects.get(id=1).delete()98 Channel.objects.get(id=2).delete()99 self.assertEquals(Channel.objects.all().count(), 0)100 print(101 " ---> test_delete_object of ChannelTestCase : OK !")102"""103 test the theme104"""105@override_settings(106 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),107 DATABASES={108 'default': {109 'ENGINE': 'django.db.backends.sqlite3',110 'NAME': 'db.sqlite',111 }112 },113 LANGUAGE_CODE='en'114)115class ThemeTestCase(TestCase):116 fixtures = ['initial_data.json', ]117 def setUp(self):118 Channel.objects.create(title="ChannelTest1")119 Theme.objects.create(120 title="Theme1", slug="blabla", channel=Channel.objects.get(title="ChannelTest1"))121 print(" ---> SetUp of ThemeTestCase : OK !")122 """123 test all attributs when a theme have been save with the minimum of attributs124 """125 def test_Theme_null_attribut(self):126 theme = Theme.objects.annotate(video_count=Count(127 "pod", distinct=True)).get(title="Theme1")128 self.assertFalse(theme.slug == slugify("blabla"))129 self.assertEqual(theme.headband, None)130 self.assertEqual(theme.__unicode__(), "ChannelTest1: Theme1")131 self.assertEqual(theme.video_count, 0)132 self.assertEqual(theme.description, None)133 self.assertEqual(134 theme.get_absolute_url(), "/" + theme.channel.slug + "/" + theme.slug + "/")135 print(136 " ---> test_Theme_null_attribut of ThemeTestCase : OK !")137 """138 test attributs when a theme have many attributs139 """140 def test_Theme_with_attributs(self):141 theme = Theme.objects.get(title="Theme1")142 theme.description = "blabla"143 self.assertEqual(theme.description, 'blabla')144 print(145 " ---> test_Theme_with_attributs of ThemeTestCase : OK !")146 """147 test delete object148 """149 def test_delete_object(self):150 Theme.objects.get(id=1).delete()151 self.assertEquals(Theme.objects.all().count(), 0)152 print(153 " ---> test_delete_object of ThemeTestCase : OK !")154"""155 test the type156"""157@override_settings(158 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),159 DATABASES={160 'default': {161 'ENGINE': 'django.db.backends.sqlite3',162 'NAME': 'db.sqlite',163 }164 },165 LANGUAGE_CODE='en'166)167class TypeTestCase(TestCase):168 def setUp(self):169 Type.objects.create(title="Type1", slug="blabla")170 print(" ---> SetUp of TypeTestCase : OK !")171 """172 test all attributs when a type have been save with the minimum of attributs173 """174 def test_Type_null_attribut(self):175 type1 = Type.objects.annotate(video_count=Count(176 "pod", distinct=True)).get(title="Type1")177 self.assertFalse(type1.slug == slugify("blabla"))178 self.assertEqual(type1.headband, None)179 self.assertEqual(type1.__unicode__(), "Type1")180 self.assertEqual(type1.video_count, 0)181 self.assertEqual(type1.description, None)182 print(183 " ---> test_Type_null_attribut of TypeTestCase : OK !")184 """185 test attributs when a type have many attributs186 """187 def test_Type_with_attributs(self):188 type1 = Type.objects.get(title="Type1")189 type1.description = "blabla"190 self.assertEqual(type1.description, 'blabla')191 print(192 " ---> test_Type_with_attributs of TypeTestCase : OK !")193 """194 test delete object195 """196 def test_delete_object(self):197 Type.objects.get(id=1).delete()198 self.assertEquals(Type.objects.all().count(), 0)199 print(200 " ---> test_delete_object of TypeTestCase : OK !")201"""202 test the discipline203"""204@override_settings(205 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),206 DATABASES={207 'default': {208 'ENGINE': 'django.db.backends.sqlite3',209 'NAME': 'db.sqlite',210 }211 },212 LANGUAGE_CODE='en'213)214class DisciplineTestCase(TestCase):215 def setUp(self):216 Discipline.objects.create(title="Discipline1", slug="blabla")217 print(" ---> SetUp of DisciplineTestCase : OK !")218 """219 test all attributs when a discipline have been save with the minimum of attributs220 """221 def test_Discipline_null_attribut(self):222 discipline = Discipline.objects.annotate(223 video_count=Count("pod", distinct=True)).get(title="Discipline1")224 self.assertFalse(discipline.slug == slugify("blabla"))225 self.assertEqual(discipline.headband, None)226 self.assertEqual(discipline.__unicode__(), "Discipline1")227 self.assertEqual(discipline.video_count, 0)228 self.assertEqual(discipline.description, None)229 print(230 " ---> test_Discipline_null_attribut of DisciplineTestCase : OK !")231 """232 test attributs when a discipline have many attributs233 """234 def test_Discipline_with_attributs(self):235 discipline = Discipline.objects.get(title="Discipline1")236 discipline.description = "blabla"237 self.assertEqual(discipline.description, 'blabla')238 print(239 " ---> test_Discipline_with_attributs of DisciplineTestCase : OK !")240 """241 test delete object242 """243 def test_delete_object(self):244 Discipline.objects.get(id=1).delete()245 self.assertEquals(Discipline.objects.all().count(), 0)246 print(247 " ---> test_delete_object of DisciplineTestCase : OK !")248"""249 test the NextAutoIncrement250"""251@override_settings(252 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),253 DATABASES={254 'default': {255 'ENGINE': 'django.db.backends.sqlite3',256 'NAME': 'db.sqlite',257 }258 },259 LANGUAGE_CODE='en'260)261class NextAutoIncrementTestCase(TestCase):262 def setUp(self):263 discipline = Discipline.objects.create(title="Discipline1")264 print(" ---> SetUp of NextAutoIncrementTestCase : OK !")265 """266 Verifie if the id is incremented267 """268 def testAutoIncrementId(self):269 if('mysql' in settings.DATABASES['default']['ENGINE']):270 self.assertEqual(get_nextautoincrement(271 Discipline), Discipline.objects.get(title="Discipline1").id + 1)272 else:273 self.assertEqual(Discipline.objects.latest(274 'id').id + 1, Discipline.objects.get(title="Discipline1").id + 1)275 print(276 " ---> testAutoIncrementId of NextAutoIncrementTestCase : OK !")277"""278 test the objet pod and Video279"""280@override_settings(281 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),282 DATABASES={283 'default': {284 'ENGINE': 'django.db.backends.sqlite3',285 'NAME': 'db.sqlite',286 }287 },288 LANGUAGE_CODE='en'289)290class VideoTestCase(TestCase):291 fixtures = ['initial_data.json', ]292 def setUp(self):293 remi = User.objects.create_user("Remi")294 other_type = Type.objects.get(id=1)295 self.media_guard_hash = get_media_guard("remi", 1)296 Pod.objects.create(297 type=other_type, title="Video1", owner=remi, video="", to_encode=False)298 Pod.objects.create(type=other_type, title="Video2", encoding_status="b", encoding_in_progress=True,299 date_added=datetime.today(), owner=remi, date_evt=datetime.today(), video=os.path.join("media", "videos", "remi", self.media_guard_hash, "test.mp4"), allow_downloading=True, view_count=2, description="fl",300 overview="blabla.jpg", is_draft=False, duration=3, infoVideo="videotest", to_encode=False)301 print(" ---> SetUp of VideoTestCase : OK !")302 """303 test all attributs when a video have been save with the minimum of attributs304 """305 def test_Video_null_attributs(self):306 pod = Pod.objects.get(id=1)307 self.assertEqual(pod.video.name, "")308 self.assertEqual(pod.allow_downloading, False)309 self.assertEqual(pod.description, '')310 self.assertFalse(pod.slug == slugify("tralala"))311 date = datetime.today()312 self.assertEqual(pod.owner, User.objects.get(username="Remi"))313 self.assertEqual(pod.date_added.year, date.year)314 self.assertEqual(pod.date_added.month, date.month)315 self.assertEqual(pod.date_added.day, date.day)316 self.assertEqual(pod.date_evt, pod.date_added)317 self.assertEqual(pod.view_count, 0)318 self.assertEqual(pod.is_draft, True)319 self.assertEqual(pod.to_encode, False)320 self.assertEqual(pod.encoding_status, None)321 self.assertEqual(pod.encoding_in_progress, False)322 self.assertEqual(pod.thumbnail, None)323 self.assertTrue(pod.to_encode == False)324 self.assertEqual(pod.duration, 0)325 self.assertEqual(pod.infoVideo, None)326 self.assertEqual(pod.get_absolute_url(), "/video/" + pod.slug + "/")327 self.assertEqual(pod.__unicode__(), "%s - %s" %328 ('%04d' % pod.id, pod.title)) # pb unicode appel str329 print(330 " ---> test_Video_null_attributs of VideoTestCase : OK !")331 """332 test attributs when a video have many attributs333 """334 def test_Video_many_attributs(self):335 pod = Pod.objects.get(id=2)336 self.assertEqual(pod.video.name, os.path.join(337 'media', 'videos', 'remi', self.media_guard_hash, 'test.mp4'))338 self.assertEqual(pod.allow_downloading, True)339 self.assertEqual(pod.description, 'fl')340 self.assertEqual(pod.overview.name, "blabla.jpg")341 self.assertEqual(pod.view_count, 2)342 self.assertEqual(pod.allow_downloading, True)343 self.assertEqual(pod.encoding_status, 'b')344 self.assertEqual(pod.to_encode, False)345 self.assertEqual(pod.is_draft, False)346 self.assertEqual(pod.encoding_in_progress, True)347 self.assertEqual(pod.duration, 3)348 self.assertEqual(pod.infoVideo, "videotest")349 self.assertEqual(pod.video.__unicode__(), pod.video.name)350 print(351 " ---> test_Video_many_attributs of VideoTestCase : OK !")352 """353 test the function admin thumbnail354 """355 def test_admin_thumbnail(self):356 video1 = Pod.objects.get(id=1)357 video2 = Pod.objects.get(id=2)358 self.assertEqual(video1.admin_thumbnail(), "")359 self.assertEqual(video2.admin_thumbnail(), "") # test dans la vue360 print(361 " ---> test_admin_thumbnail of VideoTestCase : OK !")362 """363 test the filename function364 """365 def test_filename(self):366 video1 = Pod.objects.get(id=1)367 video2 = Pod.objects.get(id=2)368 self.assertEqual(video1.filename(), "")369 self.assertEqual(video2.filename(), u'test.mp4')370 print(371 " ---> test_filename of VideoTestCase : OK !")372 """373 test the fucntion duration_in_time374 """375 def test_duration_in_time(self):376 video1 = Pod.objects.get(id=1)377 video2 = Pod.objects.get(id=2)378 self.assertEqual(video1.duration_in_time(), "00:00:00")379 self.assertEqual(video2.duration_in_time(), "00:00:03")380 print(381 " ---> test_duration_in_time of VideoTestCase : OK !")382 """383 test delete object384 """385 def test_delete_object(self):386 Pod.objects.get(id=1).delete()387 Pod.objects.get(id=2).delete()388 self.assertEquals(Pod.objects.all().count(), 0)389 print(390 " ---> test_delete_object of VideoTestCase : OK !")391 392"""393 test the contributor object394"""395@override_settings(396 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),397 DATABASES={398 'default': {399 'ENGINE': 'django.db.backends.sqlite3',400 'NAME': 'db.sqlite',401 }402 },403 LANGUAGE_CODE='en'404)405class ContributorPodsTestCase(TestCase):406 fixtures = ['initial_data.json', ]407 408 def setUp(self):409 remi = User.objects.create_user("Remi")410 other_type = Type.objects.get(id=1)411 pod = Pod.objects.create(412 type=other_type, title="Video1", slug="tralala", owner=remi)413 pod2 = Pod.objects.create(414 type=other_type, title="Video2", slug="tralalo", owner=remi)415 ContributorPods.objects.create(video=pod, name="contributor1")416 ContributorPods.objects.create(video=pod, name="contributor2", email_address="test@mail.com", role="actor", weblink="http://test.com")417 print (" ---> SetUp of ContributorPodsTestCase : OK !")418 """419 test all attributs when a contributor have been save with the minimum of attributs420 """421 def test_Contributor_null_attribut(self):422 contributor = ContributorPods.objects.get(id=1)423 self.assertEqual(contributor.video.id, 1)424 self.assertEqual(contributor.name, "contributor1")425 self.assertEqual(contributor.email_address, "")426 self.assertEqual(contributor.role, "author")427 self.assertEqual(contributor.weblink, None)428 self.assertEqual(contributor.__unicode__(), "Video:%s - Name:%s - Role:%s" % 429 (contributor.video, contributor.name, contributor.role))430 print (431 " ---> test_Contributor_null_attribut of ContributorPodsTestCase : OK !")432 """433 test attributs when a contributor have many attributs434 """435 def test_Contributor_with_attributs(self):436 contributor = ContributorPods.objects.get(id=2)437 self.assertEqual(contributor.email_address, "test@mail.com")438 self.assertEqual(contributor.role, "actor")439 self.assertEqual(contributor.weblink, "http://test.com")440 print (441 " ---> test_Contributor_with_attributs of ContributorPodsTestCase : OK !")442 """443 test delete object444 """445 def test_delete_object(self):446 ContributorPods.objects.get(id=1).delete()447 ContributorPods.objects.get(id=2).delete()448 self.assertEquals(ContributorPods.objects.all().count(), 0)449 print (450 " ---> test_delete_object of ContributorPodsTestCase : OK !")451"""452 test the trackpods object453"""454@override_settings(455 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),456 DATABASES={457 'default': {458 'ENGINE': 'django.db.backends.sqlite3',459 'NAME': 'db.sqlite',460 }461 },462 LANGUAGE_CODE='en'463)464class TrackPodsTestCase(TestCase):465 fixtures = ['initial_data.json', ]466 def setUp(self):467 remi = User.objects.create_user("Remi")468 other_type = Type.objects.get(id=1)469 pod = Pod.objects.create(470 type=other_type, title="Video1", slug="tralala", owner=remi)471 pod2 = Pod.objects.create(472 type=other_type, title="Video2", slug="tralalo", owner=remi)473 TrackPods.objects.create(video=pod, lang="en")474 TrackPods.objects.create(video=pod2, lang="fr", kind="captions")475 """476 test all attributs when a track have been save with the minimum of attributs477 """478 def test_Track_null_attribut(self):479 track = TrackPods.objects.get(id=1)480 self.assertEqual(track.video.id, 1)481 self.assertEqual(track.lang, "en")482 self.assertEqual(track.kind, "subtitles")483 self.assertEqual(track.src, None)484 self.assertEqual(track.__unicode__(), "%s - File: %s - Video: %s" % 485 (track.kind, track.src, track.video))486 print (487 " ---> test_Track_null_attribut of TrackPodsTestCase : OK !")488 """489 test attributs when a track have many attributs490 """491 def test_Track_with_attributs(self):492 track = TrackPods.objects.get(id=2)493 self.assertEqual(track.lang, "fr")494 self.assertEqual(track.kind, "captions")495 print (496 " ---> test_Track_with_attributs of TrackPodsTestCase : OK !")497 """498 test delete object499 """500 def test_delete_object(self):501 TrackPods.objects.get(id=1).delete()502 TrackPods.objects.get(id=2).delete()503 self.assertEquals(TrackPods.objects.all().count(), 0)504 print (505 " ---> test_delete_object of TrackPodsTestCase : OK !")506"""507 test the chapter object508"""509@override_settings(510 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),511 DATABASES={512 'default': {513 'ENGINE': 'django.db.backends.sqlite3',514 'NAME': 'db.sqlite',515 }516 },517 LANGUAGE_CODE='en'518)519class ChapterPodsTestCase(TestCase):520 fixtures = ['initial_data.json', ]521 def setUp(self):522 remi = User.objects.create_user("Remi")523 other_type = Type.objects.get(id=1)524 pod = Pod.objects.create(525 type=other_type, title="Video1", slug="tralala", owner=remi)526 ChapterPods.objects.create(video=pod, title="chapter1")527 ChapterPods.objects.create(video=pod, title="chapter2", time=2)528 """529 test all attributs when a chapter have been save with the minimum of attributs530 """531 def test_Chapter_null_attribut(self):532 chapter = ChapterPods.objects.get(id=1)533 self.assertEqual(chapter.video.id, 1)534 self.assertEqual(chapter.title, "chapter1")535 self.assertEqual(chapter.time, 0)536 self.assertFalse(chapter.slug == slugify("chapter1"))537 self.assertEqual(chapter.__unicode__(), "Chapter : %s - video: %s" % 538 (chapter.title, chapter.video))539 print (540 " ---> test_Chapter_null_attribut of ChapterPodsTestCase : OK !")541 """542 test attributs when a chapter have many attributs543 """544 def test_Chapter_with_attributs(self):545 chapter = ChapterPods.objects.get(id=2)546 self.assertEqual(chapter.title, "chapter2")547 self.assertEqual(chapter.time, 2)548 print (549 " ---> test_Chapter_with_attributs of ChapterPodsTestCase : OK !")550 """551 test delete object552 """553 def test_delete_object(self):554 ChapterPods.objects.get(id=1).delete()555 ChapterPods.objects.get(id=2).delete()556 self.assertEquals(ChapterPods.objects.all().count(), 0)557 print (558 " ---> test_delete_object of ChapterPodsTestCase : OK !")559 560"""561 test the overlaypods object562"""563@override_settings(564 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),565 DATABASES={566 'default': {567 'ENGINE': 'django.db.backends.sqlite3',568 'NAME': 'db.sqlite',569 }570 },571 LANGUAGE_CODE='en'572)573class OverlayPodsTestCase(TestCase):574 fixtures = ['initial_data.json', ]575 def setUp(self):576 remi = User.objects.create_user("Remi")577 other_type = Type.objects.get(id=1)578 pod = Pod.objects.create(579 type=other_type, title="Video1", slug="tralala", owner=remi)580 OverlayPods.objects.create(581 video=pod, title="overlay1", content="tralala")582 OverlayPods.objects.create(583 video=pod, title="overlay2", content="tralala", time_end=5, position="top-left")584 print(" ---> SetUp of OverlayPodsTestCase : OK !")585 """586 test atributs and str function587 """588 def test_attributs_and_str(self):589 overlay = OverlayPods.objects.get(id=1)590 overlay2 = OverlayPods.objects.get(id=2)591 self.assertEqual(overlay.video.id, 1)592 self.assertEqual(overlay.content, "tralala")593 self.assertEqual(overlay.time_start, 0)594 self.assertEqual(overlay.time_end, 1)595 self.assertEqual(overlay.position, "bottom-right")596 self.assertEqual(overlay2.time_end, 5)597 self.assertEqual(overlay2.position, "top-left")598 self.assertEqual(overlay.__unicode__(), "Overlay : %s - video: %s" %599 (overlay.title, overlay.video))600 print(601 " ---> test_attributs_and_str of OverlayPodsTestCase : OK !")602 603 def test_delete_object(self):604 OverlayPods.objects.get(id=1).delete()605 OverlayPods.objects.get(id=2).delete()606 self.assertEquals(OverlayPods.objects.all().count(), 0)607 print(608 " ---> test_delete_object of OverlayPodsTestCase : OK !")609"""610 test the favorites object611"""612@override_settings(613 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),614 DATABASES={615 'default': {616 'ENGINE': 'django.db.backends.sqlite3',617 'NAME': 'db.sqlite',618 }619 },620 LANGUAGE_CODE='en'621)622class FavoritesTestCase(TestCase):623 fixtures = ['initial_data.json', ]624 def setUp(self):625 remi = User.objects.create_user("Remi")626 other_type = Type.objects.get(id=1)627 pod = Pod.objects.create(628 type=other_type, title="Video1", slug="tralala", owner=remi)629 Favorites.objects.create(user=remi, video=pod)630 print(" ---> SetUp of FavoritesTestCase : OK !")631 """632 test attributs and str function633 """634 def test_attributs_and_str(self):635 favorite = Favorites.objects.get(id=1)636 self.assertEqual(favorite.user.username, "Remi")637 self.assertEqual(favorite.video.id, 1)638 self.assertEqual(favorite.__unicode__(), "%s-%s" %639 (favorite.user.username, favorite.video))640 print(641 " ---> test_attributs_and_str of FavoritesTestCase : OK !")642 """643 test delete object644 """645 def test_delete_object(self):646 Favorites.objects.get(id=1).delete()647 self.assertEquals(Favorites.objects.all().count(), 0)648 print(649 " ---> test_delete_object of FavoritesTestCase : OK !")650"""651 test the objet Notes652"""653@override_settings(654 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),655 DATABASES={656 'default': {657 'ENGINE': 'django.db.backends.sqlite3',658 'NAME': 'db.sqlite',659 }660 },661 LANGUAGE_CODE='en'662)663class NotesTestCase(TestCase):664 fixtures = ['initial_data.json', ]665 def setUp(self):666 remi = User.objects.create_user("Remi")667 other_type = Type.objects.get(id=1)668 pod = Pod.objects.create(669 type=other_type, title="Video1", slug="tralala", owner=remi)670 pod2 = Pod.objects.create(671 type=other_type, title="Video2", slug="tralala", owner=remi)672 Notes.objects.create(user=remi, video=pod, note="tata")673 Notes.objects.create(user=remi, video=pod2)674 print(" ---> SetUp of NotesTestCase : OK !")675 """676 test attributs and str function677 """678 def test_attributs_and_str(self):679 note = Notes.objects.get(id=1)680 note2 = Notes.objects.get(id=2)681 self.assertEqual(note.user.username, "Remi")682 self.assertEqual(note.video.id, 1)683 self.assertEqual(note.note, "tata")684 self.assertEqual(note2.note, None)685 self.assertEqual(note.__unicode__(), "%s-%s" %686 (note.user.username, note.video))687 print(688 " ---> test_attributs_and_str of NotesTestCase : OK !")689 """690 test delete object691 """692 def test_delete_object(self):693 Notes.objects.get(id=1).delete()694 Notes.objects.get(id=2).delete()695 self.assertEquals(Notes.objects.all().count(), 0)696 print(697 " ---> test_delete_object of NotesTestCase : OK !")698@override_settings(699 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),700 DATABASES={701 'default': {702 'ENGINE': 'django.db.backends.sqlite3',703 'NAME': 'db.sqlite',704 }705 },706 LANGUAGE_CODE='en'707)708class PlaylistTestCase(TestCase):709 fixtures = ['initial_data.json', ]710 def setUp(self):711 remi = User.objects.create_user("Remi")712 Playlist.objects.create(title='test1', owner=remi)713 Playlist.objects.create(title='test2', owner=remi, description='test', visible=True)714 print(" ----> SetUp of PlaylistTestCase : OK !")715 """716 test all attributs when a playlist have been save with the minimum of attributs717 """718 def test_Playlist_null_attributs(self):719 playlist = Playlist.objects.get(id=1)720 remi = User.objects.get(id=1)721 self.assertEqual(playlist.title, 'test1')722 self.assertEqual(playlist.slug, slugify('test1'))723 self.assertEqual(playlist.description, '')724 self.assertEqual(playlist.visible, False)725 self.assertEqual(playlist.owner, remi)726 print(727 " ----> test_Playlist_null_attributs of PlaylistTestCase : OK !")728 """729 test all attributs when a playlist have many attributs730 """731 def test_Playlist_with_attributs(self):732 playlist = Playlist.objects.get(id=2)733 remi = User.objects.get(id=1)734 self.assertEqual(playlist.title, 'test2')735 self.assertEqual(playlist.slug, slugify('test2'))736 self.assertEqual(playlist.description, 'test')737 self.assertEqual(playlist.visible, True)738 self.assertEqual(playlist.owner, remi)739 print(740 " ----> test_Playlist_with_attributs of PlaylistTestCase : OK !")741 """742 test delete object743 """744 def test_delete_object(self):745 Playlist.objects.get(id=1).delete()746 self.assertEqual(Playlist.objects.all().count(), 1)747 Playlist.objects.get(id=2).delete()748 self.assertEqual(Playlist.objects.all().count(), 0)749 print(750 " ----> test_delete_object of PlaylistTestCase : OK !")751@override_settings(752 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),753 DATABASES={754 'default': {755 'ENGINE': 'django.db.backends.sqlite3',756 'NAME': 'db.sqlite',757 }758 },759 LANGUAGE_CODE='en'760)761class PlaylistVideoTestCase(TestCase):762 fixtures = ['initial_data.json', ]763 def setUp(self):764 remi = User.objects.create_user("Remi")765 playlist = Playlist.objects.create(title='test1', owner=remi)766 other_type = Type.objects.get(id=1)767 pod = Pod.objects.create(768 type=other_type, title="Video1", slug="tralala", owner=remi)769 pod2 = Pod.objects.create(770 type=other_type, title="Video2", slug="tralala2", owner=remi)771 PlaylistVideo.objects.create(playlist=playlist, video=pod)772 PlaylistVideo.objects.create(playlist=playlist, video=pod2, position=1)773 print(" ----> setUp of PlaylistVideoTestCase : OK !")774 def test_attributs(self):775 pod = Pod.objects.get(id=1)776 pod2 = Pod.objects.get(id=2)777 video = PlaylistVideo.objects.get(id=1)778 video2 = PlaylistVideo.objects.get(id=2)779 playlist = Playlist.objects.get(id=1)780 self.assertEqual(video.playlist, playlist)781 self.assertEqual(video.video, pod)782 self.assertEqual(video.position, 0)783 self.assertEqual(video2.playlist, playlist)784 self.assertEqual(video2.video, pod2)785 self.assertEqual(video2.position, 1)786 print(787 " ----> test_attributs of PlaylistVideoTestCase : OK !")788 """789 test delete object790 """791 def test_delete_object(self):792 playlist = Playlist.objects.get(id=1)793 PlaylistVideo.objects.get(id=1).delete()794 self.assertEqual(PlaylistVideo.objects.all().count(), 1)795 video = PlaylistVideo.objects.get(id=2)796 video.reordering(playlist)797 self.assertEqual(PlaylistVideo.objects.get(id=2).position, 0)798 PlaylistVideo.objects.get(id=2).delete()799 self.assertEqual(PlaylistVideo.objects.all().count(), 0)800 print(801 " ----> test_delete_object of PlaylistVideoTestCase : OK !")802"""803 test the MediaCourses804"""805@override_settings(806 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),807 DATABASES={808 'default': {809 'ENGINE': 'django.db.backends.sqlite3',810 'NAME': 'db.sqlite',811 }812 },813 LANGUAGE_CODE='en'814)815class MediaCoursesTestCase(TestCase):816 fixtures = ['initial_data.json', ]817 def setUp(self):818 remi = User.objects.create_user("Remi")819 remi2 = User.objects.create_user("Remi2")820 Mediacourses.objects.create(user=remi, title="media1", date_added=timezone.now(821 ), mediapath="blabla", started=True, error="error1")822 #Mediacourses.objects.get_or_create(user=remi2, title="media2")823 Mediacourses.objects.create(user=remi2, title="media2", started=True)824 print(" ---> SetUp of MediaCoursesTestCase : OK !")825 """826 test attributs827 """828 def test_attributs(self):829 media = Mediacourses.objects.get(id=1)830 media2 = Mediacourses.objects.get(id=2)831 # test media832 self.assertEqual(media.user.username, "Remi")833 self.assertEqual(media.title, "media1")834 date = datetime.today()835 self.assertEqual(media.date_added.year, date.year)836 self.assertEqual(media.date_added.month, date.month)837 self.assertEqual(media.date_added.day, date.day)838 self.assertEqual(media.mediapath, "blabla")839 self.assertEqual(media.started, True)840 self.assertEqual(media.error, "error1")841 # test media2842 self.assertEqual(media2.date_added.strftime(843 "%d/%m/%y"), media.date_added.strftime("%d/%m/%y"))844 self.assertEqual(media2.title, "media2")845 self.assertEqual(media2.started, True)846 self.assertEqual(media2.error, None)847 print(848 " ---> test_attributs of MediaCoursesTestCase : OK !")849 """850 test delete object851 """852 def test_delete_object(self):853 Mediacourses.objects.filter(title="media1").delete()854 self.assertEquals(Mediacourses.objects.all().count(), 1)855 print(856 " ---> test_delete_object of MediaCoursesTestCase : OK !")857"""858 test building object859"""860@override_settings(861 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),862 DATABASES={863 'default': {864 'ENGINE': 'django.db.backends.sqlite3',865 'NAME': 'db.sqlite',866 }867 },868 LANGUAGE_CODE='en'869)870class BuildingTestCase(TestCase):871 def setUp(self):872 building = Building.objects.create(name="bulding1")873 print(" ---> SetUp of BuildingTestCase : OK !")874 """875 test attributs876 """877 def test_attributs(self):878 building = Building.objects.get(id=1)879 self.assertEqual(building.name, u"bulding1")880 print(881 " ---> test_attributs of BuildingTestCase : OK !")882 """883 test delete object884 """885 def test_delete_object(self):886 Building.objects.get(id=1).delete()887 self.assertEquals(Building.objects.all().count(), 0)888 print(889 " ---> test_delete_object of BuildingTestCase : OK !")890"""891 test recorder object892"""893@override_settings(894 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),895 DATABASES={896 'default': {897 'ENGINE': 'django.db.backends.sqlite3',898 'NAME': 'db.sqlite',899 }900 },901 LANGUAGE_CODE='en'902)903class RecoderTestCase(TestCase):904 fixtures = ['initial_data.json', ]905 def setUp(self):906 remi = User.objects.create_user("Remi")907 building = Building.objects.create(name="bulding1")908 image = Image.objects.create(owner=remi, original_filename="schema_bdd.jpg", file=File(909 open("schema_bdd.jpg"), "schema_bdd.jpg"))910 Recorder.objects.create(name="recorder1", image=image, adress_ip="201.10.20.10",911 status=True, slide=False, gmapurl="b", is_restricted=True, building=building)912 print(" ---> SetUp of RecoderTestCase : OK !")913 """914 test attributs915 """916 def test_attributs(self):917 record = Recorder.objects.get(id=1)918 self.assertEqual(record.name, "recorder1")919 self.assertEqual(record.image.original_filename, "schema_bdd.jpg")920 self.assertEqual(record.adress_ip, "201.10.20.10")921 self.assertEqual(record.status, True)922 self.assertEqual(record.slide, False)923 self.assertEqual(record.gmapurl, "b")924 self.assertEqual(record.is_restricted, True)925 self.assertEqual(record.building.id, 1)926 self.assertEqual(record.__unicode__(), "%s - %s" %927 (record.name, record.adress_ip))928 self.assertEqual(record.ipunder(), "201_10_20_10")929 print(930 " ---> test_attributs of RecoderTestCase : OK !")931 """932 test delete object933 """934 def test_delete_object(self):935 Recorder.objects.get(id=1).delete()936 self.assertEquals(Recorder.objects.all().count(), 0)937 print(938 " ---> test_delete_object of RecoderTestCase : OK !")939"""940 test reportVideo object941"""942@override_settings(943 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),944 DATABASES={945 'default': {946 'ENGINE': 'django.db.backends.sqlite3',947 'NAME': 'db.sqlite',948 }949 },950 LANGUAGE_CODE='en'951)952class ReportVideoTestCase(TestCase):953 fixtures = ['initial_data.json', ]954 def setUp(self):955 remi = User.objects.create_user("Remi")956 nicolas = User.objects.create_user("Nicolas")957 other_type = Type.objects.get(id=1)958 pod = Pod.objects.create(959 type=other_type, title="Video1", slug="tralala", owner=remi)960 ReportVideo.objects.create(video=pod, user=remi)961 ReportVideo.objects.create(962 video=pod, user=nicolas, comment="violation des droits", answer="accepte")963 print(" ---> SetUp of ReportVideoTestCase : OK !")964 """965 test_attributs_with_not_comment966 """967 def test_attributs_with_not_comment(self):968 reportVideo = ReportVideo.objects.get(id=1)969 self.assertEqual(reportVideo.video.id, 1)970 self.assertEqual(reportVideo.__unicode__(), "%s - %s" %971 (reportVideo.video, reportVideo.user))972 self.assertEqual(reportVideo.user.username, "Remi")973 date = datetime.today()974 self.assertEqual(reportVideo.date_added.year, date.year)975 self.assertEqual(reportVideo.date_added.month, date.month)976 self.assertEqual(reportVideo.date_added.day, date.day)977 self.assertEqual(reportVideo.comment, None)978 self.assertEqual(reportVideo.answer, None)979 yesterday = datetime.today() - timedelta(1)980 reportVideo.date = yesterday981 self.assertFalse(reportVideo.date_added.day == yesterday.day)982 print(983 " ---> test_attributs_with_not_comment of ReportVideoTestCase : OK !")984 """985 test_attributs_with_comment986 """987 def test_attributs_with_comment(self):988 reportVideo = ReportVideo.objects.get(id=2)989 self.assertEqual(reportVideo.video.id, 1)990 self.assertEqual(reportVideo.__unicode__(), "%s - %s" %991 (reportVideo.video, reportVideo.user))992 self.assertEqual(reportVideo.user.username, "Nicolas")993 date = datetime.today()994 self.assertEqual(reportVideo.date_added.year, date.year)995 self.assertEqual(reportVideo.date_added.month, date.month)996 self.assertEqual(reportVideo.date_added.day, date.day)997 self.assertEqual(reportVideo.comment, "violation des droits")998 self.assertEqual(reportVideo.answer, "accepte")999 self.assertEqual(reportVideo.get_iframe_url_to_video(),1000 reportVideo.video.get_iframe_admin_integration())1001 print(1002 " ---> test_attributs_with_comment of ReportVideoTestCase : OK !")1003 """1004 test delete object1005 """1006 def test_delete_object(self):1007 ReportVideo.objects.get(id=1).delete()1008 ReportVideo.objects.get(id=2).delete()1009 self.assertEquals(ReportVideo.objects.all().count(), 0)1010 print(1011 " ---> test_delete_object of ReportVideoTestCase : OK !")1012"""1013 test the rss1014"""1015@override_settings(1016 MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media'),1017 DATABASES={1018 'default': {1019 'ENGINE': 'django.db.backends.sqlite3',1020 'NAME': 'db.sqlite',1021 }1022 }1023)1024class RSSTestCase(TestCase):1025 fixtures = ['initial_data.json', ]1026 def setUp(self):1027 if RSS:1028 user = User.objects.create(1029 username='remi', password='12345', is_active=True, is_staff=True)1030 other_type = Type.objects.get(id=1)1031 Rssfeed.objects.create(title='test1', description="blabla",1032 link_rss='http://test.com', owner=user, fil_type_pod=other_type)1033 Rssfeed.objects.create(title='test2', description="blabla",1034 link_rss='http://test.com', owner=user, fil_type_pod=other_type, type_rss='V', year=2018, is_up=False)1035 print(" ---> SetUp of RSSTestCase : OK !")1036 """1037 test all attributs when a rssfeed have been save with the minimum of attributs1038 """1039 def test_Rssfeed_null_attribut(self):1040 if RSS:1041 date = datetime.today()1042 user = User.objects.get(username='remi')1043 rssfeed = Rssfeed.objects.get(id=1)1044 self.assertEqual(rssfeed.title, 'test1')1045 self.assertEqual(rssfeed.year, 2017)1046 self.assertEqual(rssfeed.type_rss, 'A')1047 self.assertEqual(rssfeed.is_up, True)1048 self.assertEqual(rssfeed.limit, 0)1049 self.assertEqual(rssfeed.date_update.year, date.year)1050 self.assertEqual(rssfeed.date_update.month, date.month)1051 self.assertEqual(rssfeed.date_update.day, date.day)1052 self.assertEqual(rssfeed.owner, user)1053 self.assertEqual(rssfeed.__unicode__(), rssfeed.title)1054 print(1055 " ---> test_Rssfeed_null_attribut of RSSTestCase : OK !")1056 """1057 test attributs when a rssfeed have many attributs1058 """1059 def test_Rssfeed_with_attributs(self):1060 if RSS:1061 date = datetime.today()1062 user = User.objects.get(username='remi')1063 rssfeed = Rssfeed.objects.get(id=2)1064 self.assertEqual(rssfeed.year, 2018)1065 self.assertEqual(rssfeed.type_rss, 'V')1066 self.assertEqual(rssfeed.is_up, False)1067 self.assertEqual(rssfeed.limit, 0)1068 self.assertEqual(rssfeed.date_update.year, date.year)1069 self.assertEqual(rssfeed.date_update.month, date.month)1070 self.assertEqual(rssfeed.date_update.day, date.day)1071 self.assertEqual(rssfeed.owner, user)1072 self.assertEqual(rssfeed.__unicode__(), rssfeed.title)1073 print(1074 " ---> test_Rssfeed_with_attributs of RSSTestCase : OK !")1075 """1076 test delete object1077 """1078 def test_delete_object(self):1079 if RSS:1080 Rssfeed.objects.get(id=1).delete()1081 Rssfeed.objects.get(id=2).delete()1082 self.assertEquals(Rssfeed.objects.all().count(), 0)1083 print(...

Full Screen

Full Screen

test_api.py

Source:test_api.py Github

copy

Full Screen

...52 @skip("Not implemented")53 def test_list_objects_brief(self):54 pass55 @skip("on_delete set to PROTECT")56 def test_delete_object(self):57 pass58 @skip("on_delete set to PROTECT")59 def test_bulk_delete_objects(self):60 pass61class AddressObjectGroupAPIViewTest(APIViewTestCases.APIViewTestCase):62 """Test the AddressObjectGroup viewsets."""63 model = models.AddressObjectGroup64 bulk_update_data = {"description": "test update description"}65 @classmethod66 def setUpTestData(cls):67 """Create test data for API calls."""68 create_env()69 addr_obj = models.AddressObject.objects.first()70 cls.create_data = [71 {"name": "test1", "address_objects": [addr_obj.id]},72 {"name": "test2", "address_objects": [addr_obj.id]},73 ]74 @skip("Not implemented")75 def test_list_objects_brief(self):76 pass77 @skip("on_delete set to PROTECT")78 def test_delete_object(self):79 pass80 @skip("on_delete set to PROTECT")81 def test_bulk_delete_objects(self):82 pass83 def test_create_object(self):84 self.validation_excluded_fields = ["address_objects"]85 return super().test_create_object()86 def test_update_object(self):87 self.validation_excluded_fields = ["address_objects"]88 return super().test_update_object()89 def test_bulk_create_objects(self):90 self.validation_excluded_fields = ["address_objects"]91 return super().test_bulk_create_objects()92class ServiceObjectAPIViewTest(APIViewTestCases.APIViewTestCase):93 """Test the ServiceObject viewsets."""94 model = models.ServiceObject95 bulk_update_data = {"description": "test update description"}96 choices_fields = ["ip_protocol"]97 @classmethod98 def setUpTestData(cls):99 """Create test data for API calls."""100 cls.create_data = [101 {"name": "HTTP", "port": "8088", "ip_protocol": "TCP"},102 {"name": "HTTP", "port": "8080-8088", "ip_protocol": "TCP"},103 ]104 create_env()105 @skip("Not implemented")106 def test_list_objects_brief(self):107 pass108 @skip("on_delete set to PROTECT")109 def test_delete_object(self):110 pass111 @skip("on_delete set to PROTECT")112 def test_bulk_delete_objects(self):113 pass114class ServiceGroupAPIViewTest(APIViewTestCases.APIViewTestCase):115 """Test the ServiceGroup viewsets."""116 model = models.ServiceObjectGroup117 bulk_update_data = {"description": "test update description"}118 @classmethod119 def setUpTestData(cls):120 """Create test data for API calls."""121 create_env()122 svc_obj = models.ServiceObject.objects.first()123 cls.create_data = [124 {"name": "test1", "service_objects": [svc_obj.id]},125 {"name": "test2", "service_objects": [svc_obj.id]},126 ]127 @skip("Not implemented")128 def test_list_objects_brief(self):129 pass130 @skip("on_delete set to PROTECT")131 def test_delete_object(self):132 pass133 @skip("on_delete set to PROTECT")134 def test_bulk_delete_objects(self):135 pass136 def test_create_object(self):137 self.validation_excluded_fields = ["service_objects"]138 return super().test_create_object()139 def test_update_object(self):140 self.validation_excluded_fields = ["service_objects"]141 return super().test_update_object()142 def test_bulk_create_objects(self):143 self.validation_excluded_fields = ["service_objects"]144 return super().test_bulk_create_objects()145class UserObjectAPIViewTest(APIViewTestCases.APIViewTestCase):146 """Test the User viewsets."""147 model = models.UserObject148 bulk_update_data = {"name": "User Name 123"}149 @classmethod150 def setUpTestData(cls):151 """Create test data for API calls."""152 cls.create_data = [153 {"username": "test1", "name": "Foo"},154 {"username": "test2", "name": "Bar"},155 ]156 create_env()157 @skip("Not implemented")158 def test_list_objects_brief(self):159 pass160 @skip("on_delete set to PROTECT")161 def test_delete_object(self):162 pass163 @skip("on_delete set to PROTECT")164 def test_bulk_delete_objects(self):165 pass166class UserObjectGroupAPIViewTest(APIViewTestCases.APIViewTestCase):167 """Test the UserGroup viewsets."""168 model = models.UserObjectGroup169 bulk_update_data = {"description": "test update description"}170 @classmethod171 def setUpTestData(cls):172 """Create test data for API calls."""173 create_env()174 user = models.UserObject.objects.first()175 cls.create_data = [176 {"name": "test1", "user_objects": [user.id]},177 {"name": "test2", "user_objects": [user.id]},178 ]179 @skip("Not implemented")180 def test_list_objects_brief(self):181 pass182 @skip("on_delete set to PROTECT")183 def test_delete_object(self):184 pass185 @skip("on_delete set to PROTECT")186 def test_bulk_delete_objects(self):187 pass188 def test_create_object(self):189 self.validation_excluded_fields = ["user_objects"]190 return super().test_create_object()191 def test_update_object(self):192 self.validation_excluded_fields = ["user_objects"]193 return super().test_update_object()194 def test_bulk_create_objects(self):195 self.validation_excluded_fields = ["user_objects"]196 return super().test_bulk_create_objects()197class ZoneAPIViewTest(APIViewTestCases.APIViewTestCase):198 """Test the Zone viewsets."""199 model = models.Zone200 bulk_update_data = {"description": "test update description"}201 @classmethod202 def setUpTestData(cls):203 """Create test data for API calls."""204 cls.create_data = [205 {"name": "trust"},206 {"name": "untrust"},207 ]208 create_env()209 @skip("Not implemented")210 def test_list_objects_brief(self):211 pass212 @skip("on_delete set to PROTECT")213 def test_delete_object(self):214 pass215 @skip("on_delete set to PROTECT")216 def test_bulk_delete_objects(self):217 pass218class PolicyRuleAPIViewTest(APIViewTestCases.APIViewTestCase):219 """Test the PolicyRule viewsets."""220 model = models.PolicyRule221 bulk_update_data = {"log": False}222 choices_fields = ["action"]223 @classmethod224 def setUpTestData(cls):225 """Create test data for API calls."""226 create_env()227 src_usr = models.UserObject.objects.first()228 src_addr = models.AddressObject.objects.first()229 dest_addr = models.AddressObject.objects.last()230 svc = models.ServiceObject.objects.first()231 cls.create_data = [232 {233 # pylint: disable=R0801234 "source_user": [src_usr.id],235 "source_address": [src_addr.id],236 "destination_address": [dest_addr.id],237 "action": "deny",238 "log": True,239 "service": [svc.id],240 "name": "test rule",241 },242 {243 "source_user": [src_usr.id],244 "source_address": [src_addr.id],245 "destination_address": [dest_addr.id],246 "action": "deny",247 "log": False,248 "service": [svc.id],249 "name": "test rule",250 },251 ]252 def test_list_objects_brief(self):253 pass254 @skip("on_delete set to PROTECT")255 def test_delete_object(self):256 pass257 @skip("on_delete set to PROTECT")258 def test_bulk_delete_objects(self):259 pass260class PolicyAPIViewTest(APIViewTestCases.APIViewTestCase):261 """Test the Policy viewsets."""262 model = models.Policy263 bulk_update_data = {"description": "test update description"}264 @classmethod265 def setUpTestData(cls):266 """Create test data for API calls."""267 create_env()268 pol_rule = models.PolicyRule.objects.first()269 cls.create_data = [270 {"name": "test 1", "policy_rules": [{"rule": pol_rule.id}]},271 {"name": "test 2", "policy_rules": [{"rule": pol_rule.id}], "description": "Test desc"},272 ]273 @skip("Not implemented")274 def test_list_objects_brief(self):275 pass276 def test_create_object(self):277 self.validation_excluded_fields = ["policy_rules"]278 return super().test_create_object()279 def test_update_object(self):280 self.validation_excluded_fields = ["policy_rules"]281 return super().test_update_object()282 def test_bulk_create_objects(self):283 self.validation_excluded_fields = ["policy_rules"]284 return super().test_bulk_create_objects()285 @skip("on_delete set to PROTECT")286 def test_delete_object(self):287 pass288 @skip("on_delete set to PROTECT")289 def test_bulk_delete_objects(self):...

Full Screen

Full Screen

test_package.py

Source:test_package.py Github

copy

Full Screen

...34 )35 self.assertEqual(36 updated_obj.name, "Test package updated", "test_update_object failed!"37 )38 def test_delete_object(self):39 obj = PackageManager.create_object(self.sample_obj)40 # Soft Delete41 soft_deleted_obj = PackageManager.delete_object(obj=obj, soft_delete=True)42 self.assertEqual(soft_deleted_obj.is_active, False, "test_delete_object failed")43 # Hard Delete44 deleted_obj_count, deleted_obj = PackageManager.delete_object(45 obj=obj, soft_delete=False46 )...

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 tempest 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