How to use test_create_duplicate_distro method in autotest

Best Python code snippet using autotest_python

models_unittest.py

Source:models_unittest.py Github

copy

Full Screen

...213 models.SoftwareComponentKind.objects.create(name='rpm')214 self.assertEqual(2, models.SoftwareComponentKind.objects.all().count())215 models.SoftwareComponentKind.objects.all().delete()216 self.assertEqual(0, models.SoftwareComponentKind.objects.all().count())217 def test_create_duplicate_distro(self):218 def create_kind():219 models.SoftwareComponentKind.objects.create(name='rpm')220 create_kind()221 self.assertRaises(Exception, create_kind)222 models.SoftwareComponentKind.objects.all().delete()223class SoftwareComponentArchTest(unittest.TestCase,224 test_utils.FrontendTestMixin):225 def setUp(self):226 self._frontend_common_setup()227 def tearDown(self):228 self._frontend_common_teardown()229 def test_create_delete(self):230 models.SoftwareComponentArch.objects.create(name='x86_64')231 self.assertEqual(2, models.SoftwareComponentArch.objects.all().count())232 models.SoftwareComponentArch.objects.all().delete()233 self.assertEqual(0, models.SoftwareComponentArch.objects.all().count())234 def test_create_duplicate_distro(self):235 def create_arch():236 models.SoftwareComponentArch.objects.create(name='x86_64')237 create_arch()238 self.assertRaises(Exception, create_arch)239 models.SoftwareComponentArch.objects.all().delete()240class SoftwareComponentTest(unittest.TestCase,241 test_utils.FrontendTestMixin):242 def setUp(self):243 self._frontend_common_setup()244 def tearDown(self):245 self._frontend_common_teardown()246 def test_delete_reference(self):247 '''248 Should not be possible to delete a Software Component Arch that249 is referenced by an existing Software Component250 '''251 kind = models.SoftwareComponentKind.objects.create(name='rpm')252 kind.save()253 kind_id = kind.id254 arch = models.SoftwareComponentArch.objects.create(name='x86_64')255 arch.save()256 arch_id = arch.id257 sc = models.SoftwareComponent.objects.create(name='foo',258 kind=kind,259 arch=arch,260 version='1.0.0')261 sc.save()262 sc_id = sc.id263 sc = models.SoftwareComponent.objects.get(pk=sc_id)264 arch = models.SoftwareComponentArch.objects.get(pk=arch_id)265 def arch_delete():266 arch.delete()267 self.assertRaises(dbmodels.ProtectedError, arch_delete)268 models.SoftwareComponent.objects.all().delete()269 models.SoftwareComponentKind.objects.all().delete()270 models.SoftwareComponentArch.objects.all().delete()271class LinuxDistroTest(unittest.TestCase,272 test_utils.FrontendTestMixin):273 def setUp(self):274 self._frontend_common_setup()275 def tearDown(self):276 self._frontend_common_teardown()277 def test_create_delete(self):278 # The builtin 'unknown distro' accounts for the first count279 self.assertEqual(1, models.LinuxDistro.objects.all().count())280 models.LinuxDistro.objects.create(name='distro', version='1',281 release='0', arch='i386')282 self.assertEqual(2, models.LinuxDistro.objects.all().count())283 models.LinuxDistro.objects.all().delete()284 self.assertEqual(0, models.LinuxDistro.objects.all().count())285 def test_create_query_arch_delete(self):286 models.LinuxDistro.objects.create(name='distro', version='1',287 release='0', arch='i386')288 models.LinuxDistro.objects.create(name='distro', version='1',289 release='1', arch='i386')290 models.LinuxDistro.objects.create(name='distro', version='1',291 release='0', arch='x86_64')292 models.LinuxDistro.objects.create(name='distro', version='1',293 release='1', arch='x86_64')294 all_count = models.LinuxDistro.objects.all().count()295 self.assertEqual(all_count, 5)296 i386_count = models.LinuxDistro.query_objects({'arch': 'i386'}).count()297 self.assertEqual(i386_count, 2)298 models.LinuxDistro.objects.get(name='distro', version='1',299 release='0', arch='i386').delete()300 models.LinuxDistro.objects.get(name='distro', version='1',301 release='1', arch='i386').delete()302 self.assertEqual(3, models.LinuxDistro.objects.all().count())303 def test_create_duplicate_distro(self):304 def create_distro():305 models.LinuxDistro.objects.create(name='distro', version='1',306 release='0', arch='i386')307 create_distro()308 self.assertRaises(Exception, create_distro)309 models.LinuxDistro.objects.all().delete()310if __name__ == '__main__':...

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