11from datetime import datetime , timedelta
2+ import pytest
23import uuid
34
45# Create your tests here.
@@ -2027,6 +2028,29 @@ def test_bite_is_published_on_create(self):
20272028 self .assertEqual (report .published_at , timezone .now ())
20282029 self .assertEqual (report .published , True )
20292030
2031+ @time_machine .travel ("2024-01-01 00:00:00" , tick = False )
2032+ def test_bite_is_not_published_if_country_does_not_allow_public_on_create (self ):
2033+ disabled_publish_country = EuropeCountry .objects .create (
2034+ cntr_id = "RD" , name_engl = "Random" , iso3_code = "RND" , fid = "RD" ,
2035+ geom = MultiPolygon (Polygon .from_bbox ((- 10.0 , 35.0 , 3.5 , 44.0 ))),
2036+ reports_can_be_published = False ,
2037+ )
2038+ point_on_surface = disabled_publish_country .geom .point_on_surface
2039+ report = Report .objects .create (
2040+ user = TigaUser .objects .create (),
2041+ report_id = '1234' ,
2042+ phone_upload_time = timezone .now (),
2043+ creation_time = timezone .now (),
2044+ version_time = timezone .now (),
2045+ type = Report .TYPE_BITE ,
2046+ location_choice = Report .LOCATION_CURRENT ,
2047+ current_location_lon = point_on_surface .x ,
2048+ current_location_lat = point_on_surface .y ,
2049+ )
2050+ self .assertEqual (report .country , disabled_publish_country )
2051+ self .assertIsNone (report .published_at )
2052+ self .assertEqual (report .published , False )
2053+
20302054 def test_breeding_site_with_picture_is_published_in_two_days_on_create (self ):
20312055 with time_machine .travel ("2024-01-01 00:00:00" , tick = False ) as traveller :
20322056 report = Report .objects .create (
@@ -2065,6 +2089,29 @@ def test_breeding_site_without_picture_is_published_on_create(self):
20652089 self .assertEqual (report .published_at , timezone .now ())
20662090 self .assertEqual (report .published , True )
20672091
2092+ @time_machine .travel ("2024-01-01 00:00:00" , tick = False )
2093+ def test_breeding_site_without_picture_is_not_published_if_country_does_not_allow_public_on_create (self ):
2094+ disabled_publish_country = EuropeCountry .objects .create (
2095+ cntr_id = "RD" , name_engl = "Random" , iso3_code = "RND" , fid = "RD" ,
2096+ geom = MultiPolygon (Polygon .from_bbox ((- 10.0 , 35.0 , 3.5 , 44.0 ))),
2097+ reports_can_be_published = False ,
2098+ )
2099+ point_on_surface = disabled_publish_country .geom .point_on_surface
2100+ report = Report .objects .create (
2101+ user = TigaUser .objects .create (),
2102+ report_id = '1234' ,
2103+ phone_upload_time = timezone .now (),
2104+ creation_time = timezone .now (),
2105+ version_time = timezone .now (),
2106+ type = Report .TYPE_SITE ,
2107+ location_choice = Report .LOCATION_CURRENT ,
2108+ current_location_lon = point_on_surface .x ,
2109+ current_location_lat = point_on_surface .y ,
2110+ )
2111+ self .assertEqual (report .country , disabled_publish_country )
2112+ self .assertIsNone (report .published_at )
2113+ self .assertEqual (report .published , False )
2114+
20682115 def test_adult_without_picture_is_published_on_create (self ):
20692116 report = Report .objects .create (
20702117 user = TigaUser .objects .create (),
@@ -2079,6 +2126,29 @@ def test_adult_without_picture_is_published_on_create(self):
20792126 )
20802127 self .assertEqual (report .published , True )
20812128
2129+ @time_machine .travel ("2024-01-01 00:00:00" , tick = False )
2130+ def test_adult_without_picture_is_not_published_if_country_does_not_allow_public_on_create (self ):
2131+ disabled_publish_country = EuropeCountry .objects .create (
2132+ cntr_id = "RD" , name_engl = "Random" , iso3_code = "RND" , fid = "RD" ,
2133+ geom = MultiPolygon (Polygon .from_bbox ((- 10.0 , 35.0 , 3.5 , 44.0 ))),
2134+ reports_can_be_published = False ,
2135+ )
2136+ point_on_surface = disabled_publish_country .geom .point_on_surface
2137+ report = Report .objects .create (
2138+ user = TigaUser .objects .create (),
2139+ report_id = '1234' ,
2140+ phone_upload_time = timezone .now (),
2141+ creation_time = timezone .now (),
2142+ version_time = timezone .now (),
2143+ type = Report .TYPE_ADULT ,
2144+ location_choice = Report .LOCATION_CURRENT ,
2145+ current_location_lon = point_on_surface .x ,
2146+ current_location_lat = point_on_surface .y ,
2147+ )
2148+ self .assertEqual (report .country , disabled_publish_country )
2149+ self .assertIsNone (report .published_at )
2150+ self .assertEqual (report .published , False )
2151+
20822152 def test_adult_with_picture_is_not_published_on_create (self ):
20832153 report = Report .objects .create (
20842154 user = TigaUser .objects .create (),
0 commit comments