Example #1
0
 def test_delete(self):
     table1 = Table(table_name="First Table")
     table1.save()
     leg1 = Leg(table_id=table1)
     leg1.save()
     leg1.delete()
     self.assertEqual(Leg.objects.count(), 0)
Example #2
0
    def test_invalid_data(self):
        table1 = Table(table_name="First Table")
        table1.save()
        leg1 = Leg(table_id=table1)
        leg1.save()
        try:
            with transaction.atomic():
                foot1 = Feet(radius=6, length=1.7, width=2)
                foot1.save()
        except Exception as exception:
            assert "ValidationError" in str(exception)

        try:
            with transaction.atomic():
                foot1 = Feet(length=1.7)
                foot1.save()
        except Exception as exception:
            assert "ValidationError" in str(exception)

        try:
            with transaction.atomic():
                foot1 = Feet(width=1)
                foot1.save()
        except Exception as exception:
            assert "ValidationError" in str(exception)
Example #3
0
 def test_create(self):
     table1 = Table(table_name="First Table")
     table1.save()
     leg1 = Leg(table_id=table1)
     leg1.save()
     self.assertEqual(Leg.objects.count(), 1)
     self.assertEqual(Leg.objects.get(pk=1).table_id, table1)
Example #4
0
 def test_update(self):
     table1 = Table(table_name="First Table")
     table1.save()
     assert Table.objects.get(pk=1).table_name == "First Table"
     table1.table_name = "First Updated Table"
     table1.save()
     self.assertEqual(Table.objects.get(pk=1).table_name, "First Updated Table")
Example #5
0
 def test_create_circle(self):
     table1 = Table(table_name="First Table")
     table1.save()
     leg1 = Leg(table_id=table1)
     leg1.save()
     foot1 = Feet(radius=1)
     foot1.save()
     foot1.leg.set([leg1])
     foot1.save()
     self.assertEqual(Feet.objects.count(), 1)
Example #6
0
 def test_list(self):
     table1 = Table(table_name="First Table")
     table1.save()
     table2 = Table(table_name="Second Table")
     table2.save()
     leg1 = Leg(table_id=table1)
     leg1.save()
     leg2 = Leg(table_id=table2)
     leg2.save()
     self.assertEqual(Leg.objects.count(), 2)
Example #7
0
 def test_create_rectangle(self):
     table1 = Table(table_name="First Table")
     table1.save()
     leg1 = Leg(table_id=table1)
     leg1.save()
     foot1 = Feet(length=1.7, width=2)
     foot1.save()
     foot1.leg.set([leg1])
     foot1.save()
     self.assertEqual(Feet.objects.count(), 1)
Example #8
0
    def test_set_columns(self):
        arra = TableFu.from_file(self.filename)
        arra.columns = ["State", "County", "Urban Area"]

        tabled = Table(
            title="That Stimulus", added_by=self.user, file=File(self.file), columns=["State", "County", "Urban Area"]
        )
        tabled.save()

        self.assertEqual(arra.columns, tabled.data.columns)
Example #9
0
 def test_update(self):
     table1 = Table(table_name="First Table")
     table1.save()
     table2 = Table(table_name="Second Table")
     table2.save()
     leg1 = Leg(table_id=table1)
     leg1.save()
     self.assertEqual(Leg.objects.get(pk=1).table_id, table1)
     leg1.table_id = table2
     leg1.save()
     self.assertEqual(Leg.objects.get(pk=1).table_id, table2)
Example #10
0
 def test_detail(self):
     table1 = Table(table_name="First Table")
     table1.save()
     table2 = Table(table_name="Second Table")
     table2.save()
     leg1 = Leg(table_id=table1)
     leg1.save()
     leg2 = Leg(table_id=table2)
     leg2.save()
     foot1 = Feet(length=70, width=20)
     foot1.save()
     foot1.leg.set([leg1, leg2])
     foot1.save()
     self.assertEqual(Feet.objects.get(foot_id=1).width, 20)
Example #11
0
    def test_update(self):
        table1 = Table(table_name="First Table")
        table1.save()
        leg1 = Leg(table_id=table1)
        leg1.save()
        foot1 = Feet(length=100, width=2)
        foot1.save()
        foot1.leg.set([leg1])
        foot1.save()
        self.assertEqual(Feet.objects.count(), 1)
        self.assertEqual(Feet.objects.get(foot_id=1).length, 100)

        foot1.length = 200
        foot1.save()
        self.assertEqual(Feet.objects.get(foot_id=1).length, 200)
Example #12
0
 def test_delete(self):
     table1 = Table(table_name="First Table")
     table1.save()
     table1.delete()
     self.assertEqual(Table.objects.count(), 0)
Example #13
0
def create(request):
    table = Table(id=uuid.uuid4())

    table.save()

    return JsonResponse({'id': table.id}, status=201)
Example #14
0
    def test_from_file(self):
        arra = TableFu.from_file(self.filename)
        tabled = Table(title="That Stimulus", added_by=self.user, file=File(self.file))
        tabled.save()

        self.assertEqual(arra.table, tabled.data.table)
Example #15
0
    def test_from_url(self):
        murders = TableFu.from_url(self.url)
        tabled = Table(title="DC Homicides 2010", added_by=self.user, url=self.url)
        tabled.save()

        self.assertEqual(murders.table, tabled.data.table)