-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_postings.py
149 lines (122 loc) · 6.4 KB
/
test_postings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# -*- coding: utf-8 -*-
# Copyright (C) 2016-2018, Dylan Grandmont
import unittest
import postings
import csv
import os
class TestPosting(unittest.TestCase):
def test_postings_database(self):
database = postings.PostingsDatabase("temp.csv")
posting = postings.Posting("2014.01.01",
"lease",
"12345",
"1000.00",
"1",
"100/13-24-037-03W4/00",
"Base Montney",
"Base Leduc",
"252.0",
"323.0",
"KML Polygon Content",
"AB")
database.add_row(posting)
database.write_to_csv()
database.close()
reader = csv.reader(open("temp.csv"))
content = list(reader)
self.assertEquals(content[0][0], "saleDate:contractType:contractNo:hectares:tractNo:uwi:topZone:baseZone:topAge:baseAge:geometry:province")
self.assertEquals(content[1][0], "2014.01.01:lease:12345:1000.00:1:100/13-24-037-03W4/00:Base Montney:Base Leduc:252.0:323.0:KML Polygon Content:AB")
os.remove("temp.csv")
def test_postings_aggregate_database(self):
database = postings.PostingsAggregateDatabase("temp.csv")
database.close()
reader = csv.reader(open("temp.csv"))
content = list(reader)
self.assertEquals(content[0][0], "saleDate:contractType:contractNo:hectares:centerLat:centerLng:province")
os.remove("temp.csv")
def test_posting_results_database(self):
database = postings.ResultsDatabase("temp.csv")
database.close()
reader = csv.reader(open("temp.csv"))
content = list(reader)
self.assertEquals(content[0][0], "saleDate:status:bonus:dollarPerHectare:ClientDescription:contractType:contractNo:hectares:tractNo:uwi:topZone:baseZone:topAge:baseAge:geometry:province")
os.remove("temp.csv")
def test_posting_resuts_aggregate_database(self):
database = postings.ResultsAggregateDatabase("temp.csv")
database.close()
reader = csv.reader(open("temp.csv"))
content = list(reader)
self.assertEquals(content[0][0], "saleDate:status:bonus:dollarPerHectare:ClientDescription:contractType:contractNo:hectares:centerLat:centerLng:province")
os.remove("temp.csv")
def test_posting(self):
posting = postings.Posting("2014.01.01",
"lease",
"12345",
"1000.00",
"1",
"100/13-24-037-03W4/00",
"Base Montney",
"Base Leduc",
"252.0",
"323.0",
"KML Polygon Content",
"AB")
self.assertEquals(posting.sale_date, "2014.01.01")
self.assertEquals(posting.contract_type, "lease")
self.assertEquals(posting.contract_number, "12345")
self.assertEquals(posting.hectares, "1000.00")
self.assertEquals(posting.tract_no, "1")
self.assertEquals(posting.uwi, "100/13-24-037-03W4/00")
self.assertEquals(posting.top_qualified_zone, "Base Montney")
self.assertEquals(posting.base_qualified_zone, "Base Leduc")
self.assertEquals(posting.top_age, "252.0")
self.assertEquals(posting.base_age, "323.0")
self.assertEquals(posting.kml_polygon, "KML Polygon Content")
def test_result(self):
result = postings.Result("2014.01.01",
"No Bids",
"$1000.00",
"$10.00",
"Some Company",
"Lease",
"Contract 5",
"100.00",
"Tract 1",
"100/13-24-037-03W4/00",
"Base Montney",
"Base Leduc",
"252.0",
"323.0",
"KML Polygon Content",
"AB")
self.assertEquals(result.sale_date, "2014.01.01")
self.assertEquals(result.status, "No Bids")
self.assertEquals(result.bonus, "$1000.00")
self.assertEquals(result.dollar_per_hect, "$10.00")
self.assertEquals(result.client_desc, "Some Company")
self.assertEquals(result.contract_type, "Lease")
self.assertEquals(result.contract_number, "Contract 5")
self.assertEquals(result.hectares, "100.00")
self.assertEquals(result.tract_no, "Tract 1")
self.assertEquals(result.uwi, "100/13-24-037-03W4/00")
self.assertEquals(result.top_qualified_zone, "Base Montney")
self.assertEquals(result.base_qualified_zone, "Base Leduc")
self.assertEquals(result.top_age, "252.0")
self.assertEquals(result.base_age, "323.0")
self.assertEquals(result.kml_polygon, "KML Polygon Content")
self.assertEquals(result.province, "AB")
def test_ab_postings_manager(self):
postings_database = postings.PostingsDatabase('temp_PostingsDataBase.csv')
postings_aggregate_database = postings.PostingsAggregateDatabase('temp_PostingsAggregateDataBase.csv')
results_database = postings.ResultsDatabase('temp_PostingsResultsDataBase.csv')
results_aggregate_database = postings.ResultsAggregateDatabase('temp_PostingsAggregateResultsDataBase.csv')
ab_postings_manager = postings.ABPostingsManager(postings_database,
postings_aggregate_database,
results_database,
results_aggregate_database)
os.remove('temp_PostingsDataBase.csv')
os.remove('temp_PostingsAggregateDataBase.csv')
os.remove('temp_PostingsResultsDataBase.csv')
os.remove('temp_PostingsAggregateResultsDataBase.csv')
if __name__ == '__main__':
result = unittest.main()