<commit_before>"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".

Replace these with more appropriate tests for your application.
"""

from django.test import TestCase

class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.failUnlessEqual(1 + 1, 2)

__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.

>>> 1 + 1 == 2
True
"""}
<commit_msg>Skelton of system tests for tastypie api<commit_after>from system_api import SystemResource
from systems.models import System
from tastypie.test import ResourceTestCase
class TastySystemTest(ResourceTestCase):

    def setUp(self):
        super(TastySystemTest, self).setUp()

    def create_system(self, host_dict):
        System(**host_dict).save()

    def test1_system_not_exist(self):
        resp = self.api_client.get('/api/v3/system/1/', format='json')
        self.assertEqual(resp.status_code, 404)
 
    def test2_create_system(self):
        data = {'hostname': 'foobar.vlan.dc'}
        resp = self.api_client.post('/en-US/tasty/v3/system/', format='json', data=data)
        self.assertEqual(resp.status_code, 201)

    def test3_get_system_by_id(self):
        self.create_system({'hostname':'foobar.vlan.dc'})
        resp = self.api_client.get('/en-US/tasty/v3/system/2/', format='json')
        self.assertEqual(resp.status_code, 200)


    def test4_get_system_by_hostname(self):
        self.create_system({'hostname':'foobar.vlan.dc'})
        resp = self.api_client.get('/en-US/tasty/v3/system/foobar.vlan.dc/', format='json')
        self.assertEqual(resp.status_code, 200)


    def test5_delete_system_by_id(self):
        self.create_system({'hostname':'foobar.vlan.dc'})
        self.assertEqual(len(System.objects.all()), 1)
        resp = self.api_client.get('/en-US/tasty/v3/system/foobar.vlan.dc/', format='json')
        system_id = self.deserialize(resp)['id']
        resp = self.api_client.delete('/en-US/tasty/v3/system/%i/' % system_id, format='json')
        self.assertEqual(resp.status_code, 204)
        self.assertEqual(len(System.objects.all()), 0)


    def test6_delete_system_by_hostname(self):
        self.create_system({'hostname':'foobar.vlan.dc'})
        self.assertEqual(len(System.objects.all()), 1)
        resp = self.api_client.delete('/en-US/tasty/v3/system/%s/' % 'foobar.vlan.dc', format='json')
        self.assertEqual(resp.status_code, 204)
        self.assertEqual(len(System.objects.all()), 0)
{'fraction_non_alphanumeric': 0.14461538461538462, 'fraction_numerical': 0.018846153846153846, 'mean_word_length': 3.4461538461538463, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4961226', 'n_tokens_mistral': 904, 'n_tokens_neox': 847, 'n_words': 160}