Blame view

src/alert_manager/tests.py 1.32 KB
3df2d31a   haribo   #3430 : dates are...
1
from django.test import TestCase
fafae58f   haribo   Cleaned directory
2
3
4
5
import os
import shutil
import time
import alert_manager.tasks
3df2d31a   haribo   #3430 : dates are...
6

fafae58f   haribo   Cleaned directory
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django.conf import settings

from pyrosapp.models import *

TEST_FILE = "test_voevent.xml"

TEST_FILE_PATH = os.path.join(alert_manager.tasks.VOEVENTS_PATH, TEST_FILE)

VOEVENTS_TO_SEND_PATH = "alert_manager/events_to_send"


class AlertListenerTests(TestCase):

    def setup(self):
        pass

    def test_alert_reception(self):
fafae58f   haribo   Cleaned directory
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
        if os.path.isfile(TEST_FILE_PATH):
            os.remove(TEST_FILE_PATH)
            time.sleep(3)

        shutil.copyfile(os.path.join(VOEVENTS_TO_SEND_PATH, TEST_FILE),
                        TEST_FILE_PATH)
        time.sleep(3)
        self.assertEqual(
            Alert.objects.count(), 1, "There should be 1 and only 1 alert")
        self.assertEqual(
            Request.objects.count(), 1, "There should be 1 and only 1 request")
        self.assertEqual(
            Sequence.objects.count(), 2, "There should be 2 and only 2 sequences")
        self.assertEqual(
            Album.objects.count(), 3, "There should be 3 and only 3 albums")
        self.assertEqual(
            Plan.objects.count(), 3, "There should be 3 and only 3 plans")

    def test_basic(self):
        Country.objects.create(name="TEEEEST")
        self.assertEqual(Country.objects.count(), 2, "should be 2 countries")